// 导入自定义样式
import '@/assets/main.css'
// 导入工具函数
import '@/utils/index.js'
import {createApp} from 'vue'
import {createPinia} from 'pinia'
import persistedState from 'pinia-plugin-persistedstate'
import element from 'element-plus'
import pace from 'pace-js'
import {library} from '@fortawesome/fontawesome-svg-core'
import {fas} from '@fortawesome/free-solid-svg-icons'
import {far} from '@fortawesome/free-regular-svg-icons'
import {fab} from '@fortawesome/free-brands-svg-icons'

import * as elementIcons from '@element-plus/icons-vue'
import ganttastic from '@infectoone/vue-ganttastic'
import * as echarts from 'echarts'


import {FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText} from '@fortawesome/vue-fontawesome'

import App from './App.vue'
import router from './router/index.js'
import {zhCn} from "element-plus/es/locale/index";

import permission from "@/directives/permission.js";

// 第三方配置项
const pinia = createPinia();
pinia.use(persistedState)

library.add(fas, far, fab);

// Vue示例对象
const app = createApp(App)

// 全局配置对象
app.config.globalProperties.$echarts = echarts;

pinia.use(({store}) => {
    store.$modules = import.meta.glob(["@/views/**/*.vue", "@/components/**/*.vue"])
    app.config.globalProperties.$modules = store.$modules;
})
// 注册第三方对象

app.use(pinia)
app.use(router)
app.use(element, {locale: zhCn})
app.use(ganttastic)

// 注册组件
app.component('fa-icon', FontAwesomeIcon)
app.component('fa-layers', FontAwesomeLayers)
app.component('fa-layers-text', FontAwesomeLayersText)

for (let [key, component] of Object.entries(elementIcons)) {
    app.component(key, component)
}

// 注册自定义指令
app.directive('permission', permission)
app.mount('#app')